const yiXianTongModel = require('../models/yiXianTong');

class yiXianTongController {
    async getHomeDatas (ctx, next) {
        // const cityId = ctx.params.cityId;//这是get请求时拿url后面带的参数的方式
        const cityId = ctx.request.body.cityId;//这是post请求时拿url后面带的参数的方式
    
        const data = await yiXianTongModel.getHomeDatas(cityId)

        ctx.body = data;
    }

    async getListDatas (ctx, next) {
        const cityId = ctx.request.body.cityId,
              field = ctx.request.body.field;
        
        const data = await yiXianTongModel.getListDatas(cityId, field);

        ctx.body = data;
    }

    async getDetailDatas (ctx, next) {
        const field = ctx.request.body.field,
              id = ctx.request.body.id;
      
        const data = await yiXianTongModel.getDetailDatas(field, id)

        ctx.body = data;
    }

    async searchAction (ctx, next) {
        const keyword = ctx.request.body.keyword,
              cityId = ctx.request.body.cityId;
        
        const data = await yiXianTongModel.searchAction(keyword, cityId);

        ctx.body = data;
    }
}

module.exports = new yiXianTongController();
